﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.Text.RegularExpressions;

namespace shop.until
{
    public static class taokytungaunhien
    {
        public static string GenerateID(int MinSize, int MaxSize)
        {

            string stRefID = String.Empty;

            Random random = new Random();

            int iChosenMaxSize = random.Next(MinSize, MaxSize);


            for (int x = 1; x <= iChosenMaxSize; x++)
            {

                int iCharType = random.Next(1, 3);


                switch (iCharType)
                {

                    case 1:
                        {

                            stRefID += char.ConvertFromUtf32(random.Next(48, 57));

                            break;

                        }

                    case 2:
                        {

                            stRefID += char.ConvertFromUtf32(random.Next(65, 90));

                            break;

                        }

                    case 3:
                        {

                            stRefID += char.ConvertFromUtf32(random.Next(97, 122));

                            break;

                        }

                }



                System.Threading.Thread.Sleep(1);

            }
            return stRefID;

        }
    }
    public static class XoaTiengViet
    {
        public static string RemoveSign4VietnameseString(string Input)
        {

            string English = "aAeEoOuUiIdDyY----";
            string[] Vietnamese = { "áàạảãâấầậẩẫăắằặẳẵ", "ÁÀẠẢÃÂẤẦẬẨẪĂẮẰẶẲẴ",
                    "éèẹẻẽêếềệểễ", "ÉÈẸẺẼÊẾỀỆỂỄ",
                    "óòọỏõôốồộổỗơớờợởỡ", "ÓÒỌỎÕÔỐỒỘỔỖƠỚỜỢỞỠ",
                    "úùụủũưứừựửữ", "ÚÙỤỦŨƯỨỪỰỬỮ",
                    "íìịỉĩ", "ÍÌỊỈĨ",
                    "đ", "Đ",
                    "ýỳỵỷỹ", "ÝỲỴỶỸ",
                                  " ","(",")","&"};
            StringBuilder sb = new StringBuilder();
            //duyệt từng ký tự
            foreach (char ch in Input.ToCharArray())
            {
                int i;
                //tìm ký tự unicode trong chuỗi và xác định ký tự ascii tương ứng
                for (i = 0; i < Vietnamese.Length; i++)
                    if (Vietnamese[i].Contains(ch)) break;
                if (i < Vietnamese.Length) sb.Append(English[i]);
                else sb.Append(ch);
            }
            return sb.ToString();

        }
    }
}